using System.Collections.Generic;
using System.Diagnostics;
using Rhino.Mocks;

namespace wMobinium.core.test
{
    [NUnit.Framework.TestFixture]
    public class TestSuiteRunnerTest
    {
        private TestSuiteRunner testSuiteRunner = new TestSuiteRunner();

        private MockRepository mocks = new MockRepository();

        [NUnit.Framework.Test]
        public void EnsureThatRunnerExecutesTests()
        {
            TestEventListener testEventListnerMock = mocks.CreateMock<TestEventListener>();

            testEventListnerMock.TestSuitesStart();
            LastCall.IgnoreArguments().Repeat.Any();

            testEventListnerMock.TestStart(null, null);
            LastCall.IgnoreArguments().Repeat.Any();

            testEventListnerMock.TestComplete(null, null);
            LastCall.IgnoreArguments().Repeat.Any();

            testEventListnerMock.TestSuitesComplete(null, null);
            LastCall.IgnoreArguments().Repeat.Any();

            mocks.ReplayAll();

            TestSuiteBuilderTest testSuiteBuilderTest = new TestSuiteBuilderTest();
            List<TestSuite> testSuites = testSuiteBuilderTest.CreateTestSuite();

            List<TestResult> testResults = testSuiteRunner.Run(testSuites, testEventListnerMock);
            foreach (TestResult testResult in testResults)
            {
                Trace.WriteLine(testResult);
                Trace.WriteLine("\n");
            }
        }
    }
}